package com.baosight.sczx.common.zm.cInterface.cc;

import java.util.HashMap;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.spring.SpringApplicationContext;
import com.baosight.iplat4j.core.threadlocal.UserSession;
import com.baosight.iplat4j.dao.Dao;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.basetools.TablePk;

/**
 * 操作历史模块 接口
 * <p>Title: RiskHandle.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 高强
 * @version 1.0
 * <pre>Histroy:
 *          2012-06-20 下午14:38:58  高强  Create
 *</pre>
 */
public class OperationHistory {
	
	private static Dao dao = (Dao)SpringApplicationContext.getBean("dao");
	
	/**
	 * 在生产问题处理模块 新增生产问题处理记录
	 * 引用类：ServceZMCC20.java
	 * <p>Function: Insert</p>
	 * <p>Description: </p>
	 * <p>return value:boolean</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2012-06-20 下午14:38:58  高强
	 * </p>
	 *
	 */
	public static boolean InsertOperationHistory(EiInfo inInfo, String recordType,String operateType) {
		try {
			String fdRecordId = inInfo.getCellStr("result", 0, "fdKeyId");//隐患记录ID
			if(null == UserSession.getUserId() || null == UserSession.getInSessionProperty("UserCname")) {
				return false;
			}
			String fdHandlePeople = UserSession.getInSessionProperty("UserCname").toString();//操作人Name
			
			Map<String, String> _argMap = new HashMap<String, String>();
			_argMap.put("fdKeyId", TablePk.getInstance().getNextValue("T_CC_PRODUCEPROBLEM_OPERATION"));
			_argMap.put("fdRecordId", fdRecordId);
			_argMap.put("fdRecordType", recordType);
			_argMap.put("fdOperateType", operateType);
			_argMap.put("fdOperatePerson", fdHandlePeople);
			_argMap.put("fdCreateTime", StaticTools.getDateTime());//创建时间
			
			dao.insert("ZMCCProduceproblemOperation.insert", _argMap);
		} catch (Exception e) {
			System.out.println("在操作记录 新增记录异常：" + e.getMessage());
			return false;
		} 
		return true;
	}
	
	public static boolean InsertOperationHistory(String fdRecordId, String recordType,String operateType) {
		try {
			if(null == UserSession.getUserId() || null == UserSession.getInSessionProperty("UserCname")) {
				return false;
			}
			String fdHandlePeople = UserSession.getInSessionProperty("UserCname").toString();//操作人Name
			
			Map<String, String> _argMap = new HashMap<String, String>();
			_argMap.put("fdKeyId", TablePk.getInstance().getNextValue("T_CC_PRODUCEPROBLEM_OPERATION"));
			_argMap.put("fdRecordId", fdRecordId);
			_argMap.put("fdRecordType", recordType);
			_argMap.put("fdOperateType", operateType);
			_argMap.put("fdOperatePerson", fdHandlePeople);
			_argMap.put("fdCreateTime", StaticTools.getDateTime());//创建时间
			
			dao.insert("ZMCCProduceproblemOperation.insert", _argMap);
		} catch (Exception e) {
			System.out.println("在操作记录 新增记录异常：" + e.getMessage());
			return false;
		} 
		return true;
	}
}
